<?php 
    require_once('./users/users.php');
    require_once('./db/pdo.php');
    include_once('./modules/head.php');

    $users = getUsers($dbh);
?>
<body>
    <div class="container" style="padding-top: 15px;">
        <a href="create.php" class="btn btn-success">Create user</a>
        <table class="table">
            <thead>
                <tr>
                    <td><b>Image</b></td>
                    <td><b>Name</b></td>
                    <td><b>Username</b></td>
                    <td><b>Email</b></td>
                    <td><b>Phone</b></td>
                    <td><b>Website</b></td>
                    <td><b>Actions</b></td>
                </tr>
            </thead>
            <tbody>                            
                <?php foreach ($users as $user):?>
                    <tr>                        
                        <td><img src="<?php echo $user['image'] ?>"></td>
                        <td><?php echo $user['name'] ?></td>
                        <td><?php echo $user['username'] ?></td>
                        <td><?php echo $user['email'] ?></td>
                        <td><?php echo $user['phone'] ?></td>
                        <td><?php echo $user['website'] ?></td>      
                        <td>
                            <a href="view.php?id=<?php echo $user['id'] ?>" class="btn btn-light btn-small btn-sm">View</a>   
                            <a href="edit.php?id=<?php echo $user['id'] ?>" class="btn btn-info btn-sm">Edit</a>   
                            <a href="delete.php?id=<?php echo $user['id'] ?>" class="btn btn-danger btn-sm">Delete</a>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</body>
</html>